<%--
  Created by IntelliJ IDEA.
  User: 10732
  Date: 25/2/2022
  Time: 下午 3:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/public.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/style.css"/>
</head>
<body>
<!--头部-->
<%@ include file="common/publicTop.jsp" %>
<!--时间-->
<section class="publicTime">
    <span id="time">2015年1月1日 11:11  星期一</span>
    <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器！（IE10+）</a>
</section>
<!--主体内容-->
<section class="publicMian ">
    <%@ include file="common/publicLeft.jsp" %>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>用户管理页面 >> 用户添加页面</span>
        </div>
        <div class="providerAdd">
            <form action="${pageContext.request.contextPath}/add" method="post">
                <!--div的class 为error是验证错误，ok是验证成功-->
                <div class="">
                    <label for="userId">用户编码：</label>
                    <input type="text" name="userCode" id="userId"/>
                    <span>*请输入用户编码，且不能重复</span>
                </div>
                <div>
                    <label for="userName">用户名称：</label>
                    <input type="text" name="userName" id="userName"/>
                    <span >*请输入用户名称</span>
                </div>
                <div>
                    <label for="userpassword">用户密码：</label>
                    <input type="password" name="userPassword" id="userpassword"/>
                    <span>*密码长度必须大于6位小于20位</span>

                </div>
                <div>
                    <label for="userRemi">确认密码：</label>
                    <input type="password" name="userPassword2" id="userRemi"/>
                    <span>*请输入确认密码</span>
                </div>
                <div>
                    <label >用户性别：</label>

                    <select name="gender">
                        <option value="2">男</option>
                        <option value="1">女</option>
                    </select>
                    <span></span>
                </div>
                <div>
                    <label for="data">出生日期：</label>
                    <input type="date" name="birthday" id="data"/>
                    <span >*</span>
                </div>
                <div>
                    <label for="userphone">用户电话：</label>
                    <input type="text" name="phone" id="userphone"/>
                    <span >*</span>
                </div>
                <div>
                    <label for="userAddress">用户地址：</label>
                    <input type="text" name="address" id="userAddress"/>
                </div>
                <div>
                    <label >用户类别：</label>
                    <c:forEach items="${roles}" var="role" >
                        <input type="radio" name="userRole" value="${role.id}" ${role.id==3?'checke d':''} />${role.roleName}
                    </c:forEach>


                </div>
                <div class="providerAddBtn">
                    <!--<a href="#">保存</a>-->
                    <!--<a href="userList.html">返回</a>-->
                    <input type="submit" value="保存" />
                    <input type="button" value="返回" onclick="history.back(-1)"/>
                </div>
            </form>
        </div>
    </div>
</section>
<%@ include file="common/publicBottom.jsp" %>
<script src="${pageContext.request.contextPath}/statics/js/jquery.js">

</script>
<script type="text/javascript">
    $(function() {
        $("#userId").blur(function() {
            var userCode = $("#userId").val();
            //alert("发送验证"+userCode);
     if(userCode==""||userCode==null){
     alert("为空！");
     $("#userId").parent().removeClass("ok").addClass("error");
     }else{
         $.ajax({
     "url":"${pageContext.request.contextPath}/valiUserCode",
     "type":"post",
     "data":"userCode="+userCode,
     "success":function(data){
     if(data=="find"){
         //有重名
     $("#userId").parent().removeClass("ok").addClass("error").find('span').html('有重名');
     }else{
         //可以用
    $("#userId").parent().removeClass("error").addClass("ok").find('span').html('可用');
     }
     }
         });
     }
        });
    });
</script>

</body>

</html>
